package com.example.testtouch2;

import java.util.List;

import javax.microedition.khronos.opengles.GL10;

import android.app.Activity;

import com.demo.androidgame.fx.Game;
import com.demo.androidgame.fx.Input.TouchEvent;
import com.demo.androidgame.fx.gl.Camera2D;
import com.demo.androidgame.fx.gl.SpriteBatcher;
import com.demo.androidgame.fx.impl.GLScreen;
import com.demo.androidgame.fx.math.Vector2;

public class convertScreen extends GLScreen{

	Camera2D guiCam;
    SpriteBatcher batcher;
    Vector2 touchPoint;
    World world;
//    WorldListener worldListener;
    WorldRenderer renderer; 
	Vector2 position;
	float init2 = 0.0f;
	
	public convertScreen(Game game) {
		super(game);
		
		guiCam = new Camera2D(glGraphics, 320, 480);
        batcher = new SpriteBatcher(glGraphics, 100);
        touchPoint = new Vector2();
	}
	@Override
	public void update(float deltaTime) {	
	
        List<TouchEvent> touchEvents = game.getInput().getTouchEvents();
        int len = touchEvents.size();
        for(int i = 0; i < len; i++) {
            TouchEvent event = touchEvents.get(i);                        
            if(event.type == TouchEvent.TOUCH_DOWN) {
            	continue;}

            	game.setScreen(new menuScreen(game));
        }
            }	 
	   
	

	@Override
	public void present(float deltaTime) {
			
		

			GL10 gl = glGraphics.getGL();        
	        gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
	        guiCam.setViewportAndMatrices();
	        
	        gl.glEnable(GL10.GL_TEXTURE_2D);
	        
	        batcher.beginBatch(Assets.back);
	        batcher.drawSprite(160, 240, 320, 480, Assets.backgroundRegion);
	        batcher.endBatch();
	        gl.glDisable(GL10.GL_BLEND);
	      
	    	init2 += deltaTime;
	        batcher.beginBatch(Assets.amazon0);
	        if(init2 <= 0.3f){
		        batcher.drawSprite(160, 240, 310, 100, Assets.amazon0R);}

	        
	        batcher.beginBatch(Assets.amazon1);
	        if(init2 <= 0.6f || init2 >0.3f){
		        batcher.drawSprite(160, 240, 310, 100, Assets.amazon1R);
		        batcher.endBatch();}
	        
	        batcher.beginBatch(Assets.amazon2);
	        if(init2 <= 0.9f || init2 > 0.6f){
		        batcher.drawSprite(160, 240, 310, 100, Assets.amazon2R);
		        batcher.endBatch();}
	        
	        batcher.beginBatch(Assets.amazon3);
	        if(init2 <= 2.0f || init2 > 1.5f){
		        batcher.drawSprite(160, 240, 310, 100, Assets.amazon3R);
		        batcher.endBatch();}
	        
	        batcher.beginBatch(Assets.amazon4);
	        if(init2 <= 1.2f || init2 > 0.9f){
		        batcher.drawSprite(160, 240, 310, 100, Assets.amazon4R);
		        batcher.endBatch();}
	        
	        batcher.beginBatch(Assets.amazon5);
	        if(init2 <= 1.5f || init2 > 1.2f){
		        batcher.drawSprite(160, 240, 320, 100, Assets.amazon5R);
		        batcher.endBatch();}
	        
	        batcher.beginBatch(Assets.amazon6);
	        if(init2 > 1.5f){
		        batcher.drawSprite(160, 240, 320, 100, Assets.amazon6R);
		        batcher.endBatch();} 
	      
//	        Assets.amazonSound.play(3.0f);
	}
	
          
         
	@Override
	public void pause() {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void resume() {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void dispose() {
		// TODO Auto-generated method stub
		
	}

}
